package com.dz.syndata.util;

import com.alibaba.fastjson.JSON;
import com.dz.syndata.bean.BaiduLngBean;
import com.dz.syndata.domain.server.Sys;

/**
 * 车辆GPS校准API
 */
public class BaiduLngApi {
    private BaiduLngBean baiduLngBean;

    /**
     *
     * @param x
     * @param y
     * @param ak 百度地图AK码
     * @return
     */
    public  static  BaiduLngBean  sendApi(double x,double y,String  ak,int speed){
        BaiduLngBean baiduLngBean=null;
        try {
            //车辆在行驶状态才转换
            if(speed>0){
                String result= HttpRequest.sendPost("http://api.map.baidu.com/geoconv/v1/","coords=" + x + ","
                        + y + "&from=1&to=5&ak="+ak);
                baiduLngBean = JSON.parseObject(result, BaiduLngBean.class);
                System.out.println("result"+result);
                return baiduLngBean;
            }

        } catch (Exception e) {
            baiduLngBean.setStatus(-1);
            e.printStackTrace();
            return baiduLngBean;
        }

        return null;
    }
}
